﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace Calculalouca
{
    class Options : GameObject
    {
        public static int buttonPressed = 6;
        int buttonSobMouse = 6;
        //retangulo das opções.
        Rectangle[] retangulos;
        public enum SelectedRect
        {
            SOMA,
            SUBTRACAO,
            MULTIPLICACAO,
            TRANSPOSTA,
            OPOSTA,
            DETERMINANTE
        }
        public SelectedRect operacaoSelecionada;
        public static bool option2 = false;

        public Options(Texture2D texture, Color cor) : base(texture, cor)
        {
            retangulos = new Rectangle[6];

            for (int y = 0; y < retangulos.Length; y++)
            {
                retangulos[y] = new Rectangle(30, 110 + y * 30, 20, 20);
            }
        }

        public override void Update(GameTime gameTime)
        {
            MouseState mouse = Mouse.GetState();

            for (int y = 0; y < retangulos.Length; y++)
            {
                if (retangulos[y].Contains(mouse.X, mouse.Y))
                {
                    buttonSobMouse = y;
                    if (mouse.LeftButton == ButtonState.Pressed)
                    {
                        buttonPressed = y;
                        option2 = true;
                    }
                }
            }

            switch (buttonPressed)
            {
                case 0:
                    Console.WriteLine("Soma");
                    operacaoSelecionada = SelectedRect.SOMA;
                    break;

                case 1:
                    Console.WriteLine("subtracao");
                    operacaoSelecionada = SelectedRect.SUBTRACAO;
                    break;

                case 2:
                    Console.WriteLine("multiplicacao");
                    operacaoSelecionada = SelectedRect.MULTIPLICACAO;
                    break;

                case 3:
                    Console.WriteLine("oposta");
                    operacaoSelecionada = SelectedRect.OPOSTA;
                    break;

                case 4:
                    Console.WriteLine("trasposta");
                    operacaoSelecionada = SelectedRect.TRANSPOSTA;
                    break;

                case 5:
                    Console.WriteLine("determinante");
                    operacaoSelecionada = SelectedRect.DETERMINANTE;
                    break;
            }

            base.Update(gameTime);
        }

        public override void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Begin();

            for (int y = 0; y < retangulos.Length; y++)
            {
                if (buttonPressed == y)
                {
                    spriteBatch.Draw(texture, retangulos[y], Color.Red);
                }
                else if (buttonSobMouse == y)
                {
                    spriteBatch.Draw(texture, retangulos[y], Color.Yellow);
                }
                else
                {
                    spriteBatch.Draw(texture, retangulos[y], Color.White);
                }
            }

            spriteBatch.End();

            base.Draw(spriteBatch);
        }

    }
}
